package cn.edu.sctu.sctu_lysd.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by wangfuxin on 2017-04-12.
 */

public class DateUtils {

    public final static String DATE_SDF  = "yyyy/MM/dd HH:mm";


    public static long strToDate(String dateStr, String dateFormat) throws ParseException {

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);

        Date date;
        date = sdf.parse(dateStr);

        long dateTime = date.getTime();

        return dateTime;

    }

    public static String dateToStr(long date, String dateFormat) throws ParseException {

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);

        return sdf.format(date);

    }

}
